<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme and one
 * of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query,
 * e.g., it puts together the home page when no home.php file exists.
 *
 * @link http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>
<?php do_action( 'wp_script_slider' ); ?>
<div class="fullwidthbanner-container tp-banner-container-wrapper">
	<div class="tp-banner-container">
		<div class="tp-banner" >
			<ul>
				<?php 
				$posts = get_posts(array(
					'meta_query' => array(
						array(
							'key' => 'is_home_slider', // name of custom field
							'value' => '1',
							'compare' => '=='
						)
					)
				));
				if ($posts) : 
					foreach ($posts as $num => $post) : 
						$image = get_field('image_home_slider', $post->ID);
						if(!empty($image) && $num < 5): ?>
				<!-- SLIDE  -->
				<li data-transition="random" data-slotamount="7" data-masterspeed="1500" >
					<!-- MAIN IMAGE -->
					<!-- LAYERS -->
					<!-- LAYER NR. 1 -->
					<div class="tp-caption customin fadeout rs-parallaxlevel-3"
						data-x="-122"
						data-y="12" 
						data-customin="x:0;y:0;z:0;rotationX:0;rotationY:0;rotationZ:0;scaleX:0;scaleY:0;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;"
						data-speed="500"
						data-start="1300"
						data-easing="Power3.easeInOut"
						data-elementdelay="0.1"
						data-endelementdelay="0.1"
						data-endspeed="600"
						data-captionhidden="on"
						style="z-index: 10;">
						<img src="<?php echo $image['url']; ?>"  alt="<?php echo $image['alt']; ?>"  data-bgfit="cover" data-bgposition="left top" data-bgrepeat="no-repeat">
					</div>		
					<div class="tp-caption medium_bg_asbestos sft start caption_lamson" data-x="50" data-y="350" data-speed="800" data-start="2600" data-easing="Power4.easeOut" data-endspeed="300" data-endeasing="Power1.easeIn" data-captionhidden="off">
						<h2><?php the_title() ?></h2>
						<?php if( get_field( "gia_khoi_điem" ) ): ?>
							<p>Giá: <?php the_field( "gia_khoi_điem" ); ?></p>
						<?php endif;?>
						<a href="<?php the_permalink(); ?>"> Xem thêm</a>
					</div>
					
				</li>
				<?php endif;endforeach;endif; ?>
			</ul>
			<div class="tp-bannertimer"></div>
		</div>
	</div>
</div>
<div id="page" class="container">
	<div id="main">
	<div id="main-content" class="main-content">
		<div class="row main-list-wrapper">
			<div class="row col-md-9">
				<div class="product-grid">
					<div class="title">
						<p class="name">Tài sản đấu giá</p>
						<?php
							$cat_id = get_term_by( 'slug', 'tai-san-dau-gia', 'category' )->term_id;
							$category_link = get_category_link( $cat_id );
						?>
						<p class="view-more"><a href="<?php echo esc_url( $category_link ); ?>">Xem thêm</a></p>
					</div>
					<?php query_posts('posts_per_page=6&category_name=tai-san-dau-gia&orderby=desc'); ?>
					<?php if (have_posts()): while (have_posts()) : the_post(); ?>
					<div class="product-grid-item col-sm-4 col-md-4">
						<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>">
							<?php if ( has_post_thumbnail() ):the_post_thumbnail('home-thumnails'); else: ?>
							<img src="<?php echo get_template_directory_uri().'/images/no_image.jpg'?>" title="no image">
							<?php endif;?>
						</a>
						<div class="product-grid-item-content">
							<p class="name-item"><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></p>
							<div class="short-details">
								<p><span>Mã tài sản:</span><span><?php the_field('ma_tai_san') ?></span></p>
								<p><span>Giá khởi điểm:</span><span><?php the_field('gia_khoi_điem') ?></span></p>
								<p><span>Ngày đăng:</span><span><?php the_time('G:i, j/n/Y') ?></span></p>
								<a class="view-more" href="<?php the_permalink(); ?>">Chi tiết</a>
							</div>
						</div>
					</div>
					<?php endwhile;else: ?>
					<!-- when no post -->
					<?php endif; ?>
					<?php wp_reset_query(); ?>
				</div>
				<div class="product-list">
					<div class="title">
						<p class="name">Mua bán nhà đất</p>
						<?php
							$cat_id = get_term_by( 'slug', 'mua-ban-nha-dat', 'category' )->term_id;
							$category_link = get_category_link( $cat_id );
						?>
						<p class="view-more"><a href="<?php echo esc_url( $category_link ); ?>">Xem thêm</a></p>
					</div>
					<?php query_posts('posts_per_page=6&category_name=mua-ban-nha-dat&orderby=desc'); ?>
					<?php if (have_posts()): while (have_posts()) : the_post(); ?>
					<div class="product-list-item">
						<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>">
							<?php if ( has_post_thumbnail() ):the_post_thumbnail('home-thumnails'); else: ?>
							<img src="<?php echo get_template_directory_uri().'/images/no_image.jpg'?>" title="no image">
							<?php endif;?>
						</a>
						<div class="product-list-item-content">
							<p class="name-item"><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></p>
							<p class="product-list-short-des"><?php the_excerpt(); ?></p>
							<div class="short-details-group"><p class="short-details"><span class="list-name">Giá: </span><span class="list-des"><?php the_field('gia_khoi_điem') ?></span>&nbsp;-&nbsp;<span class="list-name">Diện tích: </span><span class="list-des"><?php the_field('dien_tich') ?></span>&nbsp;-&nbsp;<span class="list-name">Vị trí: </span><span class="list-des"><?php the_field('vi_tri') ?></span></p><p class="timer"><?php the_time('G:i, j/n/Y') ?></p></div>
							<a class="view-detail" href="<?php the_permalink(); ?>">Chi tiết</a>
						</div>
					</div>
					<?php endwhile;else: ?>
					<!-- when no post -->
					<?php endif; ?>
					<?php wp_reset_query(); ?>
				</div>
			</div>
			<div class="col-md-3">
				<div class="row">
				  <div class="hot-news">
					<a class="arrow-left" href="#"></a> 
					<a class="arrow-right" href="#"></a>
					<div class="swiper-container-hotnews">
						<div class="swiper-wrapper hot-news">
							<?php query_posts(array('post__in'=>get_option('sticky_posts'), 'posts_per_page'=>1)); ?>
							<?php while (have_posts()) : the_post(); ?>
								<div class="new-product swiper-slide">
									<div class="hot-news-inner">
									<?php if ( has_post_thumbnail() ):the_post_thumbnail('home-thumnails'); else: ?>
									<img src="<?php echo get_template_directory_uri().'/images/no_image.jpg'?>" title="no image">
									<?php endif;?>
									<div class="new-product-short">
										<h4><?php the_title() ?></h4>
										<p>Mã số: <?php the_field('ma_tai_san') ?></p>
										<p>Vị trí: <?php the_field('vi_tri') ?></p>
										<p>Diện tích: <?php the_field('dien_tich') ?></p>
										<p>Giá:	<?php the_field('gia_khoi_điem') ?></p>
										<a href="<?php the_permalink(); ?>"><span>Chi tiết</span></a>
									</div>
									</div>
								</div>
							<?php endwhile; ?>
							<?php wp_reset_query(); ?>
						</div>
					</div>
					<div class="pagination"></div>
				  </div>
					<div class="news-wrapper">
						<div class="news">
							<p class="title">Tin Tức</p>
							<?php query_posts('posts_per_page=5&category_name=tin-tuc&orderby=desc'); ?>
							<?php if (have_posts()): while (have_posts()) : the_post(); ?>
							<div class="list-news">
								<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>">
									<span><?php the_title() ?></span>
									<span class="timer"><?php the_time('j/n/Y') ?></span>
								</a>
							</div>
							<?php endwhile;else: ?>
							<!-- when no post -->
							<?php endif; ?>
							<?php wp_reset_query(); ?>
						</div>
					</div>
					<div class="partner-wrapper">
						<?php echo do_shortcode('[rsSlider id="79"]') ?>
					</div>
					<div class="reference-wrapper">
						<div class="reference">
							<p class="title">Liên Kết</p>
							<?php 
								$page_slug ='lien-ket';
								$page_data = get_page_by_path($page_slug);
								$page_id = $page_data->ID;
								echo apply_filters('the_content', $page_data->post_content); 
							?>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php get_sidebar( 'content' ); ?>
	</div><!-- #main-content -->

<script type="text/javascript">
	
	  	  jQuery(document).ready(function() {
					jQuery('.tp-banner').show().revolution(
						{	
						dottedOverlay:"none",
						delay:16000,
						startwidth:1170,
						startheight:700,
						hideThumbs:200,
						
						thumbWidth:100,
						thumbHeight:50,
						thumbAmount:4,
						
						
						touchenabled:"on",
						onHoverStop:"false",
						
						swipe_velocity: 0.7,
						swipe_min_touches: 1,
						swipe_max_touches: 1,
						drag_block_vertical: false,
												
						parallax:"scroll",
						parallaxBgFreeze:"on",
						parallaxLevels:[10,20,30,40,50,60,70,80,90,100],
												
						keyboardNavigation:"off",
						
						fullWidth:"on",
						spinner:"spinner4",
						

						forceFullWidth:"on",												
					});
				});	//ready
				
				
</script>
<?php
//get_sidebar();
get_footer();